package CI.aufgabe2.cip.descriptor;

import java.util.*;

import CI.aufgabe2.cip.SymbolTable;
import CI.aufgabe2.cip.base.AbstractDescr;

public class RecordDescr extends AbstractDescr {

	private static final long serialVersionUID = 1L;

	Map<String, AbstractDescr> recsymbolTable;
	private SymbolTable symtable = null;
	public RecordDescr() {
		size = 0;
		recsymbolTable = new HashMap<String, AbstractDescr>();
		this.symtable = new SymbolTable();
	}

	public RecordDescr(int fs, Map<String, AbstractDescr> fr) {
		size = fs;
		recsymbolTable = fr;
	}

	public RecordDescr(SymbolTable table){
		this.symtable = table;		
	}
	
	public void setRecSymbolTable(Map<String, AbstractDescr> fr) {
		recsymbolTable = fr;
	}

	public AbstractDescr getDesc(String val){
		return this.symtable.getDescr(val);
	}
	public int addressOf(String s){
    	return this.symtable.getAdr(s);
    }
	public Map<String, AbstractDescr> getRecsymbolTable() {
		return recsymbolTable;
	}
	public SymbolTable getSymbolTable(){
		return this.symtable;
	}
	public void print(){
		trace("RecordDescr: size: " + size + "level: " + level);
		Iterator<AbstractDescr> it = recsymbolTable.values().iterator();
		while (it.hasNext()) it.next().print();
		unindent();
	}
}